#!/usr/bin/env bash
# 指定阿里云
ALIYUN_URL=registry.cn-hangzhou.aliyuncs.com/google_containers

# 注，此处的版本需要和安装版本一致
for i in `kubeadm config images list --kubernetes-version v1.26.0`; do
 arr=(${i//// })
 # 由于registry.k8s.io/coredns/coredns:v1.9.3有多级目录，这里只取最后一级
 imageName=${arr[${#arr[*]}-1]}
 echo ">>>>>>>>>>>>>>>>>>>>>>" $imageName
 docker pull $ALIYUN_URL/$imageName
 docker tag $ALIYUN_URL/$imageName $i
 docker rmi $ALIYUN_URL/$imageName
done;

echo "================="
docker images